@ECHO OFF
SET vsn=1.0.075
:TOP
CAll :HEADER
CALL :GETOP
CALL :GETNUMS
CALL :CALCULATE
CALL :ASK
GOTO :TOP


:GETNUMS
SET NUM1=%RANDOM:~0,2%
IF %OPNUM%==1 SET NUM2=%RANDOM:~0,1%
IF NOT %OPNUM%==1 SET NUM2=%RANDOM:~0,2%
IF %NUM2%==1 GOTO :GETNUMS
GOTO :EOF

:GETOP
SET OPNUM=
SET OPNUM=%RANDOM:~0,1%
IF %OPNUM% GTR 4 GOTO :GETOP
IF %OPNUM%==1 SET OP=*
IF %OPNUM%==2 SET OP=/
IF %OPNUM%==3 SET OP=+
IF %OPNUM%==4 SET OP=-
GOTO :EOF

:CALCULATE
SET /A ANS=NUM1 %OP% NUM2
GOTO :EOF

:ASK
ECHO.
ECHO.
SET /P usrInput=%NUM1% %OP% %NUM2% ^= 
IF "%usrInput%"=="%ANS%" GOTO :CORRECT
IF "%usrInput%"=="?" GOTO :FAIL
IF /I "%usrInput%"=="n" GOTO :EOF
ECHO Incorrect
GOTO :ASK

:CORRECT
ECHO CORRECT!
CALL :SLEEP 1
GOTO :EOF

:FAIL
ECHO Answer: %ANS%
GOTO :ASK


:HEADER
CLS
ECHO  ******************************************************************************
ECHO  *                                                                            *
ECHO  *        ******   Lectrode's Simple Mathematics Aide v%vsn%  ******        *
ECHO  *                                                                            *
ECHO  *          http://code.google.com/p/useful-scripts-by-electrodexs            *
ECHO  *                                                                            *
ECHO  ******************************************************************************
ECHO.
GOTO :EOF



:SLEEP
REM ------------------------PROGRAM SLEEP-------------------------
REM Program sleeps for %1 seconds
IF "%1"=="" SET pN=3
IF NOT "%1"=="" SET pN=%1
PING -n 2 -w 1000 127.0.0.1>NUL
PING -n %pN% -w 1000 127.0.0.1>NUL
GOTO :EOF
REM ------------------------END PROGRAM SLEEP---------------------